Package edu.uky.ai.path
Class Map
java.lang.Object
edu.uky.ai.path.Map
- All Implemented Interfaces:
java.lang.Iterable<Location>
public class Map extends java.lang.Object implements java.lang.Iterable<Location>
Represents a 2D space that may contain walls.
- Author:
- Stephen G. Ware
-
Field Summary
Fields Modifier and Type Field Description SpriteflagThe destinationintheightThe height of the spacestatic MapMAP_1An empty mapstatic MapMAP_2A map with a simple wallstatic MapMAP_3A map with 2 wallsstatic MapMAP_4A map with a long corridor leading to a dead endstatic MapMAP_5A map with a long dead end corridor on the topstatic MapMAP_6A map with a long, winding path that will fool greedy searchSpriterobotThe robotintwidthThe width of the space -
Constructor Summary
Constructors Constructor Description Map(int width, int height, edu.uky.ai.path.Map.Wall... walls)Creates a new 2D space with a give number of walls. -
Method Summary
Modifier and Type Method Description voidforEach(java.util.function.Consumer<? super Location> consumer)LocationgetLocation(int x, int y)Returns theLocationobject at the given coordinates.LocationgetLocation(Sprite sprite)java.util.Iterator<Location>iterator()
-
Field Details
-
width
public final int widthThe width of the space -
height
public final int heightThe height of the space -
robot
The robot -
flag
The destination -
MAP_1
An empty map -
MAP_2
A map with a simple wall -
MAP_3
A map with 2 walls -
MAP_4
A map with a long corridor leading to a dead end -
MAP_5
A map with a long dead end corridor on the top -
MAP_6
A map with a long, winding path that will fool greedy search
-
-
Constructor Details
-
Map
public Map(int width, int height, edu.uky.ai.path.Map.Wall... walls)Creates a new 2D space with a give number of walls.- Parameters:
width- the width of the spaceheight- the height of the spacewalls- any walls the space contains
-
-
Method Details
-
iterator
- Specified by:
iteratorin interfacejava.lang.Iterable<Location>
-
forEach
- Specified by:
forEachin interfacejava.lang.Iterable<Location>
-
getLocation
Returns theLocationobject at the given coordinates.- Parameters:
x- the horizontal positiony- the vertical position- Returns:
- a
Locationobject
-
getLocation
- Parameters:
sprite- the sprite- Returns:
- a
Locationobject at the same position
-